<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>睿途题库 - 修改密码</title>
    <script src="assets/js/tailwind.min.js"></script>
    <link href="assets/css/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/remixicon.min.css" rel="stylesheet">
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#4080FF',
                        accent: '#00B42A',
                        dark: '#1D2129',
                        light: '#F2F3F5',
                        muted: '#86909C'
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                    boxShadow: {
                        'card': '0 10px 30px -5px rgba(0, 0, 0, 0.1)',
                    },
                    animation: {
                        'float': 'float 6s ease-in-out infinite',
                    },
                    keyframes: {
                        float: {
                            '0%, 100%': { transform: 'translateY(0)' },
                            '50%': { transform: 'translateY(-10px)' },
                        }
                    }
                }
            }
        }
    </script>
    
    <!-- 自定义样式 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .bg-pattern {
                background-image: 
                    radial-gradient(circle at 10% 20%, rgba(22, 93, 255, 0.05) 0%, transparent 20%),
                    radial-gradient(circle at 80% 30%, rgba(64, 128, 255, 0.05) 0%, transparent 25%),
                    radial-gradient(circle at 40% 70%, rgba(0, 180, 42, 0.05) 0%, transparent 30%),
                    radial-gradient(circle at 90% 90%, rgba(22, 93, 255, 0.05) 0%, transparent 20%);
            }
            .animate-float {
                animation: float 6s ease-in-out infinite;
            }
            @keyframes float {
                0% { transform: translateY(0px); }
                50% { transform: translateY(-15px); }
                100% { transform: translateY(0px); }
            }
            .education-bg {
                background-image: 
                    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><defs><pattern id="pattern-circles" x="0" y="0" width="50" height="50" patternUnits="userSpaceOnUse" patternContentUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(22, 93, 255, 0.1)"></circle></pattern></defs><rect x="0" y="0" width="100%" height="100%" fill="url(%23pattern-circles)"></rect><path d="M0,150 Q250,250 500,150 T1000,150" stroke="rgba(64, 128, 255, 0.15)" stroke-width="2" fill="none"></path><path d="M0,250 Q250,150 500,250 T1000,250" stroke="rgba(0, 180, 42, 0.1)" stroke-width="2" fill="none"></path><path d="M0,350 Q250,450 500,350 T1000,350" stroke="rgba(22, 93, 255, 0.1)" stroke-width="2" fill="none"></path><circle cx="150" cy="150" r="30" fill="rgba(22, 93, 255, 0.05)"></circle><circle cx="850" cy="250" r="40" fill="rgba(0, 180, 42, 0.05)"></circle><circle cx="450" cy="350" r="25" fill="rgba(64, 128, 255, 0.05)"></circle><g transform="translate(50, 80)"><path d="M0,0 L20,0 L20,30 L0,30 Z M5,5 L15,5 L15,25 L5,25 Z" fill="rgba(22, 93, 255, 0.05)" /></g><g transform="translate(250, 120)"><path d="M5,0 L15,0 L15,30 L5,30 Z M5,15 L20,15 L15,30 L5,30 Z" fill="rgba(0, 180, 42, 0.05)" /></g><g transform="translate(750, 90)"><path d="M0,10 L15,0 L30,10 L15,20 Z M5,12 L15,17 L25,12 Z" fill="rgba(64, 128, 255, 0.05)" /></g><g transform="translate(900, 320)"><circle cx="15" cy="15" r="15" fill="rgba(22, 93, 255, 0.05)" /><path d="M5,15 L25,15 M15,5 L15,25" stroke="rgba(22, 93, 255, 0.1)" stroke-width="2" /></g><g transform="translate(400, 280)"><path d="M0,0 L30,0 L30,20 L20,20 L20,30 L10,30 L10,20 L0,20 Z" fill="rgba(0, 180, 42, 0.05)" /></g><g transform="translate(650, 380)"><path d="M5,0 L25,0 L25,30 L5,30 Z M5,10 L25,10 M5,20 L25,20" fill="none" stroke="rgba(64, 128, 255, 0.05)" stroke-width="2" /></g></svg>');
            }
            .tab-active {
                color: #165DFF;
                border-color: #165DFF;
            }
            .password-strength-bar {
                height: 4px;
                transition: width 0.3s ease;
            }
            .password-strength-text {
                transition: color 0.3s ease;
            }
        }
    </style>
</head>
<body class="font-inter bg-gray-50 min-h-screen flex flex-col items-center justify-center education-bg relative pb-20">
    <!-- 背景装饰元素 -->
    <div class="absolute inset-0 overflow-hidden -z-10">
        <div class="absolute top-10 left-10 w-40 h-40 rounded-full bg-primary/10 animate-float">
            <div class="w-full h-full flex items-center justify-center text-primary/20 text-6xl">
                <i class="ri-book-2-line"></i>
            </div>
        </div>
        <div class="absolute bottom-20 right-20 w-60 h-60 rounded-full bg-secondary/10 animate-float" style="animation-delay: -2s">
            <div class="w-full h-full flex items-center justify-center text-secondary/20 text-7xl">
                <i class="ri-graduation-cap-line"></i>
            </div>
        </div>
        <div class="absolute top-1/3 right-1/4 w-32 h-32 rounded-full bg-accent/10 animate-float" style="animation-delay: -4s">
            <div class="w-full h-full flex items-center justify-center text-accent/20 text-5xl">
                <i class="ri-lightbulb-line"></i>
            </div>
        </div>
    </div>

    <div class="mt-20">
        <!-- 修改密码卡片 -->
        <div class="w-full max-w-md px-6 py-8 bg-white rounded-2xl shadow-card relative overflow-hidden">
            <!-- 顶部装饰条 -->
            <div class="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary to-accent"></div>
            
            <!-- 标题区域 -->
            <div class="text-center mb-6">
                <h1 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-dark">睿途题库-修改密码</h1>
                <p class="text-muted mt-2">设置您的新密码</p>
            </div>
            
            <!-- 修改密码表单 -->
            <form id="changePasswordForm" class="space-y-5">
                <!-- 新密码 -->
                <div class="space-y-2">
                    <label for="newPassword" class="block text-sm font-medium text-dark">新密码</label>
                    <div class="relative">
                        <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                            <i class="ri-lock-line"></i>
                        </span>
                        <input type="password" id="newPassword" name="newPassword" 
                               class="w-full pl-10 pr-10 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                               placeholder="请输入新密码">
                        <button type="button" id="toggleNewPassword" class="absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-primary transition-colors">
                            <i class="ri-eye-off-line"></i>
                        </button>
                    </div>
                    
                    <!-- 密码强度指示器 -->
                    <div class="mt-1">
                        <div class="flex space-x-1">
                            <div id="strength-1" class="password-strength-bar w-1/4 bg-gray-200 rounded-full"></div>
                            <div id="strength-2" class="password-strength-bar w-1/4 bg-gray-200 rounded-full"></div>
                            <div id="strength-3" class="password-strength-bar w-1/4 bg-gray-200 rounded-full"></div>
                            <div id="strength-4" class="password-strength-bar w-1/4 bg-gray-200 rounded-full"></div>
                        </div>
                        <p id="strength-text" class="text-xs text-muted mt-1 password-strength-text">密码强度: 未输入</p>
                    </div>
                </div>
                
                <!-- 确认新密码 -->
                <div class="space-y-2">
                    <label for="confirmPassword" class="block text-sm font-medium text-dark">确认新密码</label>
                    <div class="relative">
                        <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                            <i class="ri-lock-line"></i>
                        </span>
                        <input type="password" id="confirmPassword" name="confirmPassword" 
                               class="w-full pl-10 pr-10 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                               placeholder="请再次输入新密码">
                        <button type="button" id="toggleConfirmPassword" class="absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-primary transition-colors">
                            <i class="ri-eye-off-line"></i>
                        </button>
                    </div>
                    <p id="password-match" class="text-xs text-red-500 hidden">两次输入的密码不一致</p>
                </div>
                
                <!-- 验证码 -->
                <div class="space-y-2">
                    <label for="verificationCode" class="block text-sm font-medium text-dark">验证码</label>
                    <div class="flex space-x-3">
                        <div class="relative flex-1">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="ri-shield-line"></i>
                            </span>
                            <input type="text" id="verificationCode" name="verificationCode" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入验证码">
                        </div>
                        <div class="flex items-center">
                            <div id="captchaImage" class="w-36 h-12 bg-gray-100 rounded-lg flex items-center justify-center text-dark font-bold tracking-wider select-none">
                                <!-- 验证码将由JavaScript生成 -->
                            </div>
                            <button type="button" id="refreshCaptcha" class="ml-2 text-muted hover:text-primary transition-colors">
                                <i class="ri-refresh-line"></i>
                            </button>
                        </div>
                    </div>
                </div>
                
                <!-- 提交按钮 -->
                <button type="submit" class="w-full py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-all duration-200 transform hover:-translate-y-1 hover:shadow-lg flex items-center justify-center">
                    <span>确认修改</span>
                    <i class="ri-check-line ml-2"></i>
                </button>
                
                <!-- 返回登录 -->
                <div class="text-center text-sm">
                    <a href="#" class="text-primary hover:underline">返回登录</a>
                </div>
            </form>
        </div>
    </div>

    <!-- 页脚 -->
    <div class="absolute bottom-6 text-center text-sm text-muted">
        <p>© 2023 睿途题库. 保留所有权利.</p>
    </div>

    <!-- JavaScript -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const newPasswordInput = document.getElementById('newPassword');
            const confirmPasswordInput = document.getElementById('confirmPassword');
            const toggleNewPasswordBtn = document.getElementById('toggleNewPassword');
            const toggleConfirmPasswordBtn = document.getElementById('toggleConfirmPassword');
            const passwordMatchText = document.getElementById('password-match');
            const strengthBars = [
                document.getElementById('strength-1'),
                document.getElementById('strength-2'),
                document.getElementById('strength-3'),
                document.getElementById('strength-4')
            ];
            const strengthText = document.getElementById('strength-text');
            const verificationCodeInput = document.getElementById('verificationCode');
            const captchaImage = document.getElementById('captchaImage');
            const refreshCaptchaBtn = document.getElementById('refreshCaptcha');
            const changePasswordForm = document.getElementById('changePasswordForm');
            
            // 生成验证码
            function generateCaptcha() {
                const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
                let captcha = '';
                for (let i = 0; i < 4; i++) {
                    captcha += chars.charAt(Math.floor(Math.random() * chars.length));
                }
                return captcha;
            }
            
            // 初始化验证码
            captchaImage.textContent = generateCaptcha();
            
            // 刷新验证码
            refreshCaptchaBtn.addEventListener('click', function() {
                captchaImage.textContent = generateCaptcha();
            });
            
            // 切换密码可见性
            toggleNewPasswordBtn.addEventListener('click', function() {
                const type = newPasswordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                newPasswordInput.setAttribute('type', type);
                this.querySelector('i').classList.toggle('ri-eye-off-line');
                this.querySelector('i').classList.toggle('ri-eye-line');
            });
            
            toggleConfirmPasswordBtn.addEventListener('click', function() {
                const type = confirmPasswordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                confirmPasswordInput.setAttribute('type', type);
                this.querySelector('i').classList.toggle('ri-eye-off-line');
                this.querySelector('i').classList.toggle('ri-eye-line');
            });
            
            // 检查密码匹配
            confirmPasswordInput.addEventListener('input', function() {
                if (newPasswordInput.value !== confirmPasswordInput.value) {
                    passwordMatchText.classList.remove('hidden');
                } else {
                    passwordMatchText.classList.add('hidden');
                }
            });
            
            // 密码强度检测
            newPasswordInput.addEventListener('input', function() {
                const password = this.value;
                let strength = 0;
                
                // 密码长度
                if (password.length >= 8) strength++;
                if (password.length >= 12) strength++;
                
                // 密码复杂度
                if (/[A-Z]/.test(password)) strength++;
                if (/[0-9]/.test(password)) strength++;
                if (/[^A-Za-z0-9]/.test(password)) strength++;
                
                // 更新强度条
                strengthBars.forEach((bar, index) => {
                    if (index < strength) {
                        if (strength === 1) {
                            bar.className = 'password-strength-bar w-1/4 bg-red-500 rounded-full';
                        } else if (strength === 2) {
                            bar.className = 'password-strength-bar w-1/4 bg-yellow-500 rounded-full';
                        } else if (strength === 3) {
                            bar.className = 'password-strength-bar w-1/4 bg-blue-500 rounded-full';
                        } else {
                            bar.className = 'password-strength-bar w-1/4 bg-green-500 rounded-full';
                        }
                    } else {
                        bar.className = 'password-strength-bar w-1/4 bg-gray-200 rounded-full';
                    }
                });
                
                // 更新强度文本
                let strengthLabel = '未输入';
                let strengthColor = 'text-muted';
                
                if (strength === 0) {
                    strengthLabel = '未输入';
                    strengthColor = 'text-muted';
                } else if (strength === 1) {
                    strengthLabel = '弱';
                    strengthColor = 'text-red-500';
                } else if (strength === 2) {
                    strengthLabel = '中';
                    strengthColor = 'text-yellow-500';
                } else if (strength === 3) {
                    strengthLabel = '强';
                    strengthColor = 'text-blue-500';
                } else {
                    strengthLabel = '非常强';
                    strengthColor = 'text-green-500';
                }
                
                strengthText.textContent = `密码强度: ${strengthLabel}`;
                strengthText.className = `text-xs ${strengthColor} mt-1 password-strength-text`;
            });
            
            // 表单提交
            changePasswordForm.addEventListener('submit', function(e) {
                e.preventDefault();
                
                // 验证新密码
                if (!newPasswordInput.value) {
                    alert('请输入新密码');
                    newPasswordInput.focus();
                    return;
                }
                
                // 验证确认密码
                if (!confirmPasswordInput.value) {
                    alert('请确认新密码');
                    confirmPasswordInput.focus();
                    return;
                }
                
                // 验证密码匹配
                if (newPasswordInput.value !== confirmPasswordInput.value) {
                    alert('两次输入的密码不一致');
                    confirmPasswordInput.focus();
                    return;
                }
                
                // 验证验证码
                if (!verificationCodeInput.value) {
                    alert('请输入验证码');
                    verificationCodeInput.focus();
                    return;
                }
                
                if (verificationCodeInput.value.toUpperCase() !== captchaImage.textContent.toUpperCase()) {
                    alert('验证码不正确');
                    verificationCodeInput.focus();
                    return;
                }
                
                // 验证通过，提交表单
                // 在实际项目中，这里应该是一个AJAX请求或页面跳转
                alert('密码修改成功！请使用新密码登录');
                
                // 重置表单
                changePasswordForm.reset();
                captchaImage.textContent = generateCaptcha();
                passwordMatchText.classList.add('hidden');
                
                // 重置强度指示器
                strengthBars.forEach(bar => {
                    bar.className = 'password-strength-bar w-1/4 bg-gray-200 rounded-full';
                });
                strengthText.textContent = '密码强度: 未输入';
                strengthText.className = 'text-xs text-muted mt-1 password-strength-text';
            });
        });
    </script>
</body>
</html>
